<?php
require("libraries/student.php");
class Omini extends Student{
    public function __construct(){
        parent::__construct();
        $this->load->model("omini_model");
    }
    public function index(){
        $config['base_url'] = base_url().'admin/omini/index/';
        $config['total_rows'] = $this->omini_model->count_all();
        $config['per_page'] = 10;
        $config['uri_segment'] = 4;
        $this->load->library("pagination");
        $this->pagination->initialize($config);
        $start = $this->uri->segment(4);
        $data['title']="Quản lý đơn đặt hàng";
        $data['data']['info']= $this->omini_model->listorder($config['per_page'],$start);
        $data['template'] = "omini/list_order";
        $this->load->view("layout",$data);
    }
    public function order_view(){
        $data['title'] = "Đơn đặt hàng của khách hàng";
        $data['template'] = "omini/order_view";
        $data['data'] = "";
        $data['all'] = $this->omini_model->order_view($this->uri->segment(4));
        $this->load->view("layout",$data);
    }
    public function active(){
        $id   	= $this->uri->segment(4);
        $status	= $this->uri->segment(5);
        $db = array(
            "om_status" => $status
        );
        $this->omini_model->update_status($db,$id);
        redirect(base_url()."admin/omini/");
    }
    public function del(){
        $id = $this->uri->segment(4);
        $this->omini_model->del($id);
        redirect(base_url()."admin/omini");
    }
}